//
//  TravelCell.m
//  FairyDream
//
//  Created by dllo on 15/8/21.
//  Copyright (c) 2015年 dreams. All rights reserved.
//

#import "TravelCell.h"
#import "TravelsModel.h"
#import "UIImageView+WebCache.h"
#define Width 375 // 屏幕宽度
#define Height 200 // 屏幕高度

@interface TravelCell ()
@property (nonatomic, retain) UIImageView *bigImageV;
@property (nonatomic, retain) UILabel *titleLable;
@property (nonatomic, retain) UILabel *timeDataTimesLable;
@property (nonatomic, retain) UILabel *placeLable;
@property (nonatomic, retain) UIImageView *headerImage;
@property (nonatomic, retain) UILabel *nameLable;
@property (nonatomic, retain) UIView *clearView;

@end


@implementation TravelCell

- (void)dealloc
{
    [_bigImageV release];
    [_titleLable release];
    [_timeDataTimesLable release];
    [_placeLable release];
    [_headerImage release];
    [_nameLable release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createImageView];
    }
    return self;
}


- (void)createImageView
{
    // 视图的图片
    self.bigImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, Width, Height - 5)];
    _bigImageV.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_bigImageV];
    [_bigImageV release];
    
    // 半透明的View
    self.clearView = [[UIView alloc] initWithFrame:CGRectMake(0, 5, Width, Height - 5)];
    _clearView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_clearView];
    [_clearView release];
    
    // 标题Lable
    self.titleLable = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 350, 30)];
    self.titleLable.backgroundColor = [UIColor clearColor];
    self.titleLable.textColor = [UIColor whiteColor];
    [self.titleLable setFont:[UIFont fontWithName:@"Courier-Bold" size:20]];
    [self.contentView addSubview:_titleLable];
    [_titleLable release];
    
    // 时间 天数 次数
    self.timeDataTimesLable = [[UILabel alloc] initWithFrame:CGRectMake(15, 45, 170, 15)];
    self.timeDataTimesLable.backgroundColor = [UIColor clearColor];
    [self.timeDataTimesLable setFont:[UIFont fontWithName:@"Courier-Bold" size:10]];
    self.timeDataTimesLable.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_timeDataTimesLable];
    [_timeDataTimesLable release];
    
    
    // 地点Lable
    self.placeLable = [[UILabel alloc] initWithFrame:CGRectMake(15, 60, 100, 15)];
    self.placeLable.backgroundColor = [UIColor clearColor];
    [self.placeLable setFont:[UIFont fontWithName:@"Courier-Bold" size:10]];
    self.placeLable.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_placeLable];
    [_placeLable release];
    
    // 头像图片
    self.headerImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 160, 30, 30)];
    self.headerImage.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_headerImage];
    _headerImage.layer.masksToBounds = YES;
    _headerImage.layer.cornerRadius = 15;
    [_headerImage release];
    
    // 名字Lable
    self.nameLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 165, 150, 25)];
    self.nameLable.backgroundColor = [UIColor clearColor];
    [self.nameLable setFont:[UIFont fontWithName:@"Courier-Bold" size:12]];
    self.nameLable.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_nameLable];
    [_nameLable release];
    
}

- (void)setModelWithTravelCell:(TravelsModel *)model
{
    [self.bigImageV sd_setImageWithURL:[NSURL URLWithString:model.cover_image] placeholderImage:nil];
    self.titleLable.text = [NSString stringWithFormat:@"%@", model.name];
    self.timeDataTimesLable.text = [NSString stringWithFormat:@"%@ %@ 天  %@ 次浏览", model.first_day, model.day_count, model.view_count];
    self.placeLable.text = [NSString stringWithFormat:@"%@", model.popular_place_str];
    [self.headerImage sd_setImageWithURL:[NSURL URLWithString:model.avatar_m] placeholderImage:nil];
    self.nameLable.text = [NSString stringWithFormat:@"by %@", model.personName];
}







@end
